Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

fix: bignumber format by time formatter #1307

Merged
merged 3 commits into from
Sep 1, 2021

Conversation

zhaoyongjie
Copy link
Contributor

🏆 Enhancements
closes: apache/superset#16221

Support timestamp format in BigNumber viz

image

Test instruction:

  1. Select birth_names dataset
  2. Switch to Big Number viz
  3. Select Max(ds) as Metric
  4. Select TimeStamp format checkbox

@zhaoyongjie zhaoyongjie requested a review from a team as a code owner August 13, 2021 04:53
@vercel
Copy link

vercel bot commented Aug 13, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/superset/superset-ui/7ARZGfTidB5zxyFxhjZdTGbG4n9T
✅ Preview: https://superset-ui-git-fork-zhaoyongjie-bignumber-superset.vercel.app

@codecov
Copy link

codecov bot commented Aug 13, 2021

Codecov Report

Merging #1307 (83eebff) into master (4ea3b3d) will increase coverage by 0.52%.
The diff coverage is 16.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1307      +/-   ##
==========================================
+ Coverage   29.94%   30.46%   +0.52%     
==========================================
  Files         485      489       +4     
  Lines        9819    10129     +310     
  Branches     1644     1796     +152     
==========================================
+ Hits         2940     3086     +146     
- Misses       6644     6797     +153     
- Partials      235      246      +11     
Impacted Files Coverage Δ
...reset-chart-big-number/src/BigNumber/BigNumber.tsx 0.00% <0.00%> (ø)
...hart-big-number/src/BigNumberTotal/controlPanel.ts 0.00% <0.00%> (ø)
...t-chart-big-number/src/BigNumber/transformProps.ts 49.09% <50.00%> (-0.91%) ⬇️
...chart-controls/src/shared-controls/dndControls.tsx 35.00% <0.00%> (-3.89%) ⬇️
...-ui-chart-controls/src/components/ColumnOption.tsx 76.00% <0.00%> (-0.93%) ⬇️
packages/superset-ui-core/src/color/ColorScheme.ts 100.00% <0.00%> (ø)
...ugins/plugin-chart-echarts/src/Timeseries/types.ts 100.00% <0.00%> (ø)
...s/legacy-plugin-chart-country-map/src/countries.ts 0.00% <0.00%> (ø)
...ugin-chart-echarts/src/Timeseries/controlPanel.tsx 40.00% <0.00%> (ø)
...perset-ui-chart-controls/src/utils/D3Formatting.ts 100.00% <0.00%> (ø)
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ea3b3d...83eebff. Read the comment docs.

config: {
type: 'SelectControl',
freeForm: true,
label: t('Timestamp format'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we name it Date format for consistency with other charts?
Also, instead of adding a checkbox to control visibility, why don't we just make this select button clearable?

Copy link
Contributor Author

@zhaoyongjie zhaoyongjie Aug 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need an explicit way to tell the user whether to use number formatter or datetime formatter

@junlincc junlincc changed the title feat: bignumber format by time formatter fix: bignumber format by time formatter Aug 13, 2021
@@ -135,7 +135,7 @@ describe('BigNumber', () => {
},
};
const transformed = transformProps(propsWithDatasource);
expect(transformed.formatNumber(transformed.bigNumber)).toStrictEqual('1.23');
expect(transformed.headerFormatter(transformed.bigNumber)).toStrictEqual('1.23');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for timestamp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will push a separate PR after this. Thanks!

@@ -146,7 +147,9 @@ export default function transformProps(chartProps: BigNumberChartProps) {
});
}

const formatNumber = getNumberFormatter(yAxisFormat);
const headerFormatter = headerFormatSelector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename headerFormatSelector to isFormatTimestamp or something like that? It's not obvious that it's a boolean value which is true if formatter is for timestamp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will push a separate PR after this. Thanks!

Copy link
Contributor

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 unblocking comments, other than that LGTM

@zhaoyongjie zhaoyongjie merged commit 7b1dffa into apache-superset:master Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bignumber]display a specific date in the dataset as bigumber
2 participants